<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								外部单号：<input type="text" name="outOrderId"/>
							</li>
							<li>
								内部单号：<input type="text" name="orderNo"/>
							</li>
							<li>
								<input type="hidden" id="orderUserId" name="params[orderUserId]"/>
								<input type="hidden" id="orderUserType" name="params[orderUserType]"/>
								用户：<input type="text" id="orderUserName" name="orderUserName" onclick="selectOrderUser()" readonly="true"/>
							</li>
							<li>
								订单状态：<select name="inState" th:with="type=${@dict.getType('pay_order_in_state')}">
								<option value="">所有</option>
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
							</select>

							<li>
							完成状态：<select name="params[inComplateOrder]">
								<option value="">所有</option>
								<option value="1">已完成</option>
								<option value="0">未完成</option>
							</select>

							<li class="select-time">
								<label>下单时间： </label>
								<input type="text" class="date-time-input" id="startCreateTime" placeholder="开始" name="params[beginCreateTime]"/>
								<span>-</span>
								<input type="text" class="date-time-input" id="endCreateTime" placeholder="结束" name="params[endCreateTime]"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="resetSearch()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
                <a class="btn btn-primary btn-edit disabled" onclick="$.operate.detail()" shiro:hasPermission="manager_order_detail">
                    <i class="fa fa-edit"></i> 详情
                </a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="manager_order_export">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var prefix = ctx + "manager/order";
        var modelName = "orderin";
        var logicType = "order_in";
        var handleAuthFlagFlag = [[${@permission.hasPermi('manager_order_edit')}]];
        var payTypeDir = [[${@dict.getType('pay_type')}]];
        var orderInStateDir = [[${@dict.getType('pay_order_in_state')}]];
        var tokenUnit = [[${tokenUnit}]];
        var fabiUnit = [[${fabiUnit}]];
        $(function() {
            var options = {
                url: prefix + "/list/"+logicType,
                updateUrl: prefix + "/edit/"+modelName+"/"+logicType+"/{id}",
                detailUrl: prefix + "/"+modelName+"/"+logicType+"/{id}",
                exportUrl: prefix + "/export/"+logicType,
                modalName: "入金订单",
				search: false,
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id',
					title : '编号',
					visible: true
				},
				{
					field : 'orderNo',
					title : '内部单号',
					sortable: false
				},
				{
					field : 'outOrderId', 
					title : '外部单号',
                    sortable: false
				},
				{
					field : 'payType',
					title : '入金方式',
					sortable: true,
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(payTypeDir, value);
					}
				},
				{
					field : 'usdtNo',
					title : '充值数量(TOKEN)',
					sortable: true,
					formatter: function(value, row, index) {
						return value + tokenUnit;
					}
				},
				{
					field : 'currencyNum',
					title : '充值金额(法币)',
					sortable: true,
					formatter: function(value, row, index) {
						return value + fabiUnit;
					}
				},
				{
					field : 'client',
					title : '付款信息',
					sortable: true
				},
				{
					field : 'usdtNum',
					title : '商户入金(TOKEN)',
					sortable: true,
					formatter: function(value, row, index) {
						return value + tokenUnit;
					}
				},
				{
					field : 'plantFeeRate',
					title : '平台手续费率',
                    formatter: function(value, row, index) {
                        return (value * 100) + '%';
                    }
				},
				{
					field : 'plantFee',
					title : '平台手续费金额(TOKEN)',
					sortable: false,
					formatter: function(value, row, index) {
						return value + tokenUnit;
					}
				},
				{
					field : 'aerchantFee',
					title : '商户收益(TOKEN)',
					sortable: false,
					formatter: function(value, row, index) {
						return value + tokenUnit;
					}
				},
				{
					field : 'agentFeeRate', 
					title : '代理抽成比例',
                    formatter: function(value, row, index) {
                        return (value * 100) + '%';
                    }
				},
				{
					field : 'agentFee', 
					title : '代理抽成金额',
                    sortable: false,
                    formatter: function(value, row, index) {
                        return value + tokenUnit;
                    }
				},
				{
					field : 'acceptFee', 
					title : '承兑商收益',
                    sortable: false,
                    formatter: function(value, row, index) {
                        return value + tokenUnit;
                    }
				},
				{
					field : 'inState',
					title : '订单状态',
					sortable: true,
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(orderInStateDir, value);
					}
				},
				{
					field : 'createTime',
					title : '下单时间',
					sortable: true
				},
				{
					field : 'objectionName',
					title : '提出异议用户',
                    sortable: false
				},
				{
					field : 'objectionCreateTime', 
					title : '提出异议时间',
                    sortable: false
				},
				{
					title: '操作',
					align: 'center',
					formatter: function(value, row, index) {
						var actions = [];
                        //
                        if(row.inState == '4' || row.inState == 'A') {
                            actions.push('<a class="btn btn-info btn-xs ' + handleAuthFlagFlag + '" href="#" onclick="$.operate.startChart(\'' + row.id + '\')"><i class="fa fa-weixin"></i>聊天</a> ');
                        }
						//ZC_CDS("B", "承兑商提出仲裁")
						if(row.inState == 'B') {
                            actions.push('<a class="btn btn-info btn-xs ' + handleAuthFlagFlag + '" href="#" onclick="$.operate.startChart(\'' + row.id + '\')"><i class="fa fa-weixin"></i>查看聊天记录</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + handleAuthFlagFlag + '" href="#" onclick="$.operate.startBoHui(\'' + row.id + '\', 1)"><i class="fa fa-check"></i>仲裁入金成功</a> ');
                            actions.push('<a class="btn btn-warning btn-xs ' + handleAuthFlagFlag + '" href="#" onclick="$.operate.startBoHui(\'' + row.id + '\', 0)"><i class="fa fa-warning"></i>仲裁入金失败</a> ');
						}
						//ZC_SH("5", "商户提出仲裁")
						if(row.inState == '5') {
                            actions.push('<a class="btn btn-info btn-xs ' + handleAuthFlagFlag + '" href="#" onclick="$.operate.startChart(\'' + row.id + '\')"><i class="fa fa-weixin"></i>查看聊天记录</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + handleAuthFlagFlag + '" href="#" onclick="$.operate.startBoHui(\'' + row.id + '\', 1)"><i class="fa fa-check"></i>仲裁入金成功</a> ');
                            actions.push('<a class="btn btn-warning btn-xs ' + handleAuthFlagFlag + '" href="#" onclick="$.operate.startBoHui(\'' + row.id + '\', 0)"><i class="fa fa-warning"></i>仲裁入金失败</a> ');
						}
						return actions.join('');
					}
				}
			]
            };
            $.table.init(options);
        });

        function resetSearch() {
            $("#orderUserId").val('');
            $("#orderUserType").val('');
            $.form.reset();
        }

        /*查询订单用户*/
        function selectOrderUser() {
            var options = {
                title: '选择用户',
                width: "800",
                height: "800",
                url: ctx + "manager/user/select_user",
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
            var orderUserId = body.find('#treeId').val();
            if(!orderUserId){
                    $.modal.alertWarning("请至少选择一条记录");
                    return;
			}
			$("#orderUserId").val(orderUserId);
			$("#orderUserType").val(body.find('#roleId').val());
			$("#orderUserName").val(body.find('#treeName').val());
			layer.close(index);
        }
    </script>
</body>
</html>